# coding=utf-8
import hashlib

def main():
	data = open(ur'mybroken.zip').read()
	for i in range(len(data)):  # 遍历，每个位置都尝试修复
		for c in range(256): # 尝试改为每个可能的ASCII字符
			newdata = data[:i] + chr(c) + data[i+1:]
			if hashlib.md5(newdata).hexdigest() == 'bbb8b499a0eef99b52c7f13f4e78c24b':
				open(ur'repaired.zip', 'wb').write(newdata)
				print 'repaired.'
				return

if __name__ == '__main__':
	main()
	# 解压缩里面一幅画mybroken.gif
	# 'speed' 
	# 打开：http://www.pythonchallenge.com/pc/hex/speed.html
	# 可是网页不存在
	# 图片下的提示：Hurry up, I'm missing the boat 
	# 'Hurry up'跟speed有点关系吧，，，看来少了boat
	# 应该是speedboat
	# 下一关：http://www.pythonchallenge.com/pc/hex/speedboat.html
